package Unicart.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import static org.openqa.selenium.support.ui.ExpectedConditions.*;

public class ForgotPasswordPage extends AnyPage {

  public ForgotPasswordPage(PageManager pages) {
	super(pages);
  }

  @FindBy(id = "forgotpassword_email")
  private WebElement forgotpasswordEmailField;

  @FindBy(name = "submit")
  private WebElement sendButton;
  
  public ForgotPasswordPage setForgotPasswordEmailField(String text) {
	forgotpasswordEmailField.sendKeys(text);
	return this;
  }

  public ForgotPasswordPage ensurePageLoaded() {
	super.ensurePageLoaded();
	wait.until(presenceOfElementLocated(By.cssSelector("input#forgotpassword_email")));
	wait.until(presenceOfElementLocated(By.cssSelector("div.b-page-content_in h1")));
	return this;
  }
	  
  //TODO не на InternalPage - поправить
  public InternalPage clickSendButton() {
	sendButton.click();
	return pages.internalPage;
  }
}
